package com.rwaste.clientuser.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.rwaste.clientuser.entity.ClientAddressUser;
import com.rwaste.clientuser.service.ClientAddressUserService;
import com.rwaste.commonutils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wxc
 * @since 2021-10-06
 */
@RestController
@RequestMapping("/clientuser/address")
public class ClientAddressUserController {

    @Autowired
    private ClientAddressUserService clientAddressUserService;

    /**
     * 根据用户id查询对应的地址信息
     * @param userId 用户id
     * @return 统一返回类型Msg
     */
    @GetMapping("/getAddressByUserId/{userId}")
    public Msg getAddressByUserId(@PathVariable("userId") String userId){
        QueryWrapper<ClientAddressUser> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", userId);
        List<ClientAddressUser> list = clientAddressUserService.list(wrapper);
        return Msg.success().add("list", list);
    }

}

